package com.example.auth.config;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class CustomAuthenticationToken extends UsernamePasswordAuthenticationToken {

    private String userId;
    private Map<String, Object> additionalInfo;

    public CustomAuthenticationToken(Object principal, Object credentials,
                                     String userId,
                                     Collection<? extends GrantedAuthority> authorities) {
        super(principal, credentials, authorities);
        this.userId = userId;
        this.additionalInfo = new HashMap<>();
        this.additionalInfo.put("user_id", userId);
    }

    // getter 方法
    public String getUserId() {
        return userId;
    }


    public Map<String, Object> getAdditionalInfo() {
        return additionalInfo;
    }
}
